/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * STAFF_EDIT.java
 *
 * Created on Sep 29, 2010, 1:13:36 PM
 */

package COMIC_BOOK_STORE;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;


/**
 *
 * @author Alexander
 */
public class STAFF_EDIT extends javax.swing.JFrame {

    Connection con;
    Statement stat;
    ResultSet rset;

    /** Creates new form STAFF_EDIT */
    public STAFF_EDIT() throws SQLException {
        super("EDIT STAFF");
        initComponents();
        this.setLocationRelativeTo(null);
        connect();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jLayeredPane1 = new javax.swing.JLayeredPane();
        staffCityLabel = new javax.swing.JLabel();
        staffHouseLabel = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        choiceTextField = new javax.swing.JTextField();
        displayHousePhoneNumber = new javax.swing.JTextField();
        jSeparator1 = new javax.swing.JSeparator();
        findButton = new javax.swing.JButton();
        displaymobilePhoneNumber = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        staffAddressDetailLabel = new javax.swing.JLabel();
        staffHousephoneLabel = new javax.swing.JLabel();
        displayLastName = new javax.swing.JTextField();
        displayIcNumber = new javax.swing.JTextField();
        staffMobilePhoneLabel = new javax.swing.JLabel();
        staffFirstNameLabel = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        staffPrivilege = new javax.swing.JComboBox();
        staffLastNameLabel = new javax.swing.JLabel();
        staffYearComboBox = new javax.swing.JComboBox();
        staffPhoneDetailLabel = new javax.swing.JLabel();
        staffGenderLabel = new javax.swing.JLabel();
        staffICNumberLabel = new javax.swing.JLabel();
        jSeparator3 = new javax.swing.JSeparator();
        displayFirstName = new javax.swing.JTextField();
        staffDayComboBox = new javax.swing.JComboBox();
        staffStateComboBox = new javax.swing.JComboBox();
        staffPrivilegeLabel = new javax.swing.JLabel();
        staffDOBLabel = new javax.swing.JLabel();
        staffMonthComboBox = new javax.swing.JComboBox();
        staffPersonalDetailLabel = new javax.swing.JLabel();
        displayCity = new javax.swing.JTextField();
        staffComplexLabel = new javax.swing.JLabel();
        staffStreetLabel = new javax.swing.JLabel();
        displayPostcode = new javax.swing.JTextField();
        resetButton = new javax.swing.JButton();
        displayStreet = new javax.swing.JTextField();
        updateButton = new javax.swing.JButton();
        displayComplex = new javax.swing.JTextField();
        staffPostcodeLabel = new javax.swing.JLabel();
        displayHouseNum = new javax.swing.JTextField();
        staffStateLabel = new javax.swing.JLabel();
        mainMenuButton = new javax.swing.JButton();
        displayPriviledge = new javax.swing.JTextField();
        displayDOB = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        displayState = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        genderComboBox = new javax.swing.JComboBox();
        displayGender = new javax.swing.JTextField();
        editButton = new javax.swing.JButton();
        backButton = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        staffCityLabel.setText("City");
        staffCityLabel.setBounds(490, 220, 120, 30);
        jLayeredPane1.add(staffCityLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffHouseLabel.setText("Apartment/House No.");
        staffHouseLabel.setBounds(490, 140, 160, 20);
        jLayeredPane1.add(staffHouseLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select", "Staff Code", "IC Number" }));
        jComboBox1.setBounds(210, 20, 140, 30);
        jLayeredPane1.add(jComboBox1, javax.swing.JLayeredPane.DEFAULT_LAYER);
        choiceTextField.setBounds(390, 20, 230, 30);
        jLayeredPane1.add(choiceTextField, javax.swing.JLayeredPane.DEFAULT_LAYER);

        displayHousePhoneNumber.setFocusable(false);
        displayHousePhoneNumber.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                displayHousePhoneNumberActionPerformed(evt);
            }
        });
        displayHousePhoneNumber.setBounds(180, 440, 170, 30);
        jLayeredPane1.add(displayHousePhoneNumber, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jSeparator1.setBounds(0, 60, 900, 10);
        jLayeredPane1.add(jSeparator1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        findButton.setText("FIND");
        findButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                findButtonActionPerformed(evt);
            }
        });
        findButton.setBounds(650, 20, 100, 30);
        jLayeredPane1.add(findButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        displaymobilePhoneNumber.setFocusable(false);
        displaymobilePhoneNumber.setBounds(180, 480, 170, 30);
        jLayeredPane1.add(displaymobilePhoneNumber, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel1.setText("Lookup by");
        jLabel1.setBounds(30, 20, 150, 30);
        jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffAddressDetailLabel.setText("Address Details");
        staffAddressDetailLabel.setBounds(490, 70, 130, 20);
        jLayeredPane1.add(staffAddressDetailLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffHousephoneLabel.setText("House");
        staffHousephoneLabel.setBounds(50, 450, 100, 20);
        jLayeredPane1.add(staffHousephoneLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        displayLastName.setFocusable(false);
        displayLastName.setBounds(230, 180, 130, 30);
        jLayeredPane1.add(displayLastName, javax.swing.JLayeredPane.DEFAULT_LAYER);

        displayIcNumber.setFocusable(false);
        displayIcNumber.setBounds(230, 220, 170, 30);
        jLayeredPane1.add(displayIcNumber, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffMobilePhoneLabel.setText("Mobile");
        staffMobilePhoneLabel.setBounds(50, 480, 90, 30);
        jLayeredPane1.add(staffMobilePhoneLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffFirstNameLabel.setText("First Name");
        staffFirstNameLabel.setBounds(40, 140, 90, 20);
        jLayeredPane1.add(staffFirstNameLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jSeparator2.setBounds(0, 0, -1, -1);
        jLayeredPane1.add(jSeparator2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffPrivilege.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select", "Admin", "Employee" }));
        staffPrivilege.setEnabled(false);
        staffPrivilege.setBounds(350, 100, 100, 30);
        jLayeredPane1.add(staffPrivilege, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffLastNameLabel.setText("Last Name");
        staffLastNameLabel.setBounds(40, 180, 120, 20);
        jLayeredPane1.add(staffLastNameLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffYearComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Year", "1970", "1971", "1972", "1973", "1974", "1975", "1976", "1977", "1978", "1979", "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998" }));
        staffYearComboBox.setEnabled(false);
        staffYearComboBox.setBounds(360, 310, 80, 30);
        jLayeredPane1.add(staffYearComboBox, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffPhoneDetailLabel.setText("Phone Details");
        staffPhoneDetailLabel.setBounds(40, 430, 100, 20);
        jLayeredPane1.add(staffPhoneDetailLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffGenderLabel.setText("Gender");
        staffGenderLabel.setBounds(40, 360, 110, 30);
        jLayeredPane1.add(staffGenderLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffICNumberLabel.setText("IC Number");
        staffICNumberLabel.setBounds(40, 220, 140, 30);
        jLayeredPane1.add(staffICNumberLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jSeparator3.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator3.setBounds(0, 0, -1, -1);
        jLayeredPane1.add(jSeparator3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        displayFirstName.setFocusable(false);
        displayFirstName.setBounds(230, 140, 130, 30);
        jLayeredPane1.add(displayFirstName, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffDayComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Day", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));
        staffDayComboBox.setEnabled(false);
        staffDayComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                staffDayComboBoxActionPerformed(evt);
            }
        });
        staffDayComboBox.setBounds(170, 310, 70, 30);
        jLayeredPane1.add(staffDayComboBox, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffStateComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select", "Perlis", "Kedah", "Pulau Pinang", "Perak", "Kuala Lumpur", "Selangor", "Negeri Sembilan", "Melaka", "Pahang", "Johor", "Kelantan", "Terengganu", "Sabah", "Sarawak", " " }));
        staffStateComboBox.setEnabled(false);
        staffStateComboBox.setBounds(660, 370, 140, 30);
        jLayeredPane1.add(staffStateComboBox, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffPrivilegeLabel.setText("Priviledge Classification");
        staffPrivilegeLabel.setBounds(40, 100, 170, 30);
        jLayeredPane1.add(staffPrivilegeLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffDOBLabel.setText("Date of Birth");
        staffDOBLabel.setBounds(40, 300, 100, 30);
        jLayeredPane1.add(staffDOBLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffMonthComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }));
        staffMonthComboBox.setEnabled(false);
        staffMonthComboBox.setBounds(250, 310, 100, 30);
        jLayeredPane1.add(staffMonthComboBox, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffPersonalDetailLabel.setText("Personal Details");
        staffPersonalDetailLabel.setBounds(40, 70, 160, 20);
        jLayeredPane1.add(staffPersonalDetailLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        displayCity.setFocusable(false);
        displayCity.setBounds(660, 220, 150, 30);
        jLayeredPane1.add(displayCity, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffComplexLabel.setText("Complex/Garden");
        staffComplexLabel.setBounds(490, 180, 130, 30);
        jLayeredPane1.add(staffComplexLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffStreetLabel.setText("Street/Road");
        staffStreetLabel.setBounds(490, 100, 130, 30);
        jLayeredPane1.add(staffStreetLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        displayPostcode.setFocusable(false);
        displayPostcode.setBounds(660, 260, 100, 30);
        jLayeredPane1.add(displayPostcode, javax.swing.JLayeredPane.DEFAULT_LAYER);

        resetButton.setText("RESET");
        resetButton.setEnabled(false);
        resetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resetButtonActionPerformed(evt);
            }
        });
        resetButton.setBounds(640, 430, 100, 40);
        jLayeredPane1.add(resetButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        displayStreet.setFocusable(false);
        displayStreet.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                displayStreetActionPerformed(evt);
            }
        });
        displayStreet.setBounds(660, 100, 220, 30);
        jLayeredPane1.add(displayStreet, javax.swing.JLayeredPane.DEFAULT_LAYER);

        updateButton.setText("UPDATE");
        updateButton.setEnabled(false);
        updateButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updateButtonActionPerformed(evt);
            }
        });
        updateButton.setBounds(580, 480, 100, 40);
        jLayeredPane1.add(updateButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        displayComplex.setFocusable(false);
        displayComplex.setBounds(660, 180, 220, 30);
        jLayeredPane1.add(displayComplex, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffPostcodeLabel.setText("Postcode");
        staffPostcodeLabel.setBounds(490, 260, 110, 30);
        jLayeredPane1.add(staffPostcodeLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        displayHouseNum.setFocusable(false);
        displayHouseNum.setBounds(660, 140, 220, 30);
        jLayeredPane1.add(displayHouseNum, javax.swing.JLayeredPane.DEFAULT_LAYER);

        staffStateLabel.setText("State");
        staffStateLabel.setBounds(500, 350, 110, 30);
        jLayeredPane1.add(staffStateLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        mainMenuButton.setText("MAIN MENU");
        mainMenuButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mainMenuButtonActionPerformed(evt);
            }
        });
        mainMenuButton.setBounds(790, 480, 120, 40);
        jLayeredPane1.add(mainMenuButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        displayPriviledge.setFocusable(false);
        displayPriviledge.setBounds(230, 100, 110, 30);
        jLayeredPane1.add(displayPriviledge, javax.swing.JLayeredPane.DEFAULT_LAYER);

        displayDOB.setFocusable(false);
        displayDOB.setBounds(220, 270, 130, 30);
        jLayeredPane1.add(displayDOB, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jLabel2.setBounds(30, 260, 420, 90);
        jLayeredPane1.add(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        displayState.setFocusable(false);
        displayState.setBounds(660, 330, 140, 30);
        jLayeredPane1.add(displayState, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jLabel3.setBounds(470, 70, 420, 240);
        jLayeredPane1.add(jLabel3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jLabel4.setBounds(20, 70, 440, 330);
        jLayeredPane1.add(jLabel4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jLabel5.setBounds(20, 410, 440, 110);
        jLayeredPane1.add(jLabel5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        genderComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Male", "Female" }));
        genderComboBox.setEnabled(false);
        genderComboBox.setBounds(280, 360, 90, 30);
        jLayeredPane1.add(genderComboBox, javax.swing.JLayeredPane.DEFAULT_LAYER);

        displayGender.setFocusable(false);
        displayGender.setBounds(180, 360, 90, 30);
        jLayeredPane1.add(displayGender, javax.swing.JLayeredPane.DEFAULT_LAYER);

        editButton.setText("EDIT");
        editButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editButtonActionPerformed(evt);
            }
        });
        editButton.setBounds(480, 480, 90, 40);
        jLayeredPane1.add(editButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        backButton.setText("BACK");
        backButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backButtonActionPerformed(evt);
            }
        });
        backButton.setBounds(690, 480, 90, 40);
        jLayeredPane1.add(backButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel6.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jLabel6.setBounds(470, 320, 420, 100);
        jLayeredPane1.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGE_REPOSITORY/Background5 copy.jpg"))); // NOI18N
        jLabel7.setBounds(0, 0, 940, 550);
        jLayeredPane1.add(jLabel7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 940, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>                        

    private void staffDayComboBoxActionPerformed(java.awt.event.ActionEvent evt) {                                                 
        // TODO add your handling code here:
}                                                

    private void updateButtonActionPerformed(java.awt.event.ActionEvent evt) {                                             

        String dd = (String) staffDayComboBox.getSelectedItem();
        String mm = (String) staffMonthComboBox.getSelectedItem();
        String yy = (String) staffYearComboBox.getSelectedItem();

        String prev = (String) staffPrivilege.getSelectedItem();
        String fname = displayFirstName.getText();
        String lname = displayLastName.getText();
        String ic_no = displayIcNumber.getText();
        String date = dd+mm+yy;
        String gender = (String) genderComboBox.getSelectedItem();
        String hphone = displayHousePhoneNumber.getText();
        String mphone = displaymobilePhoneNumber.getText();
        String street = displayStreet.getText();
        String housenum = displayHouseNum.getText();
        String complex = displayComplex.getText();
        String city = displayCity.getText();
        String pcode = displayPostcode.getText();
        String state = (String) staffStateComboBox.getSelectedItem();

        String choice = choiceTextField.getText();
        String combo_select = (String) jComboBox1.getSelectedItem();

        String query = null;
        if(combo_select.equals("Staff Code"))
        {

             query = "UPDATE STAFF SET STAFF_FNAME = '"+ fname +"',STAFF_LNAME = '"+ lname +"',STAFF_ICNO = "+
                        "'"+ ic_no +"',STAFF_DOB = '"+ date +"',STAFF_GENDER = '"+ gender +"',"+
                        "STAFF_HOUSENO = '"+ housenum +"',STAFF_GARDEN = '"+ complex +"',"+
                        "STAFF_STREET = '"+ street +"',STAFF_POSTCODE = '"+ pcode +"',"+
                        "STAFF_CITY = '"+ city +"',STAFF_STATE = '"+ state +"',STAFF_HOUSEPHONE = '"+ hphone +"',"+
                        "STAFF_MOBILEPHONE = '"+ mphone +"',STAFF_CLASS = '"+ prev +"' WHERE STAFF_CODE = '"+ choice +"'";
        }

        if(combo_select.equals("IC Number"))
        {

             query = "UPDATE STAFF SET STAFF_FNAME = '"+ fname +"',STAFF_LNAME = '"+ lname +"',STAFF_ICNO = "+
                        "'"+ ic_no +"',STAFF_DOB = '"+ date +"',STAFF_GENDER = '"+ gender +"',"+
                        "STAFF_HOUSENO = '"+ housenum +"',STAFF_GARDEN = '"+ complex +"',"+
                        "STAFF_STREET = '"+ street +"',STAFF_POSTCODE = '"+ pcode +"',"+
                        "STAFF_CITY = '"+ city +"',STAFF_STATE = '"+ state +"',STAFF_HOUSEPHONE = '"+ hphone +"',"+
                        "STAFF_MOBILEPHONE = '"+ mphone +"',STAFF_CLASS = '"+ prev +"' WHERE STAFF_ICNO = '"+ choice +"'";
        }

        if(fname.equals("")|| lname.equals("")|| ic_no.equals("")|| date.equals("")|| gender.equals("")||
                housenum.equals("")||complex.equals("")||street.equals("")||pcode.equals("")||city.equals("")||
                state.equals("")||hphone.equals("")||mphone.equals("")||prev.equals(""))
        {
            JOptionPane.showMessageDialog(null, "Please Fill and Select first!");
        }
    else
    {

        try
        {
            stat = con.createStatement();
            stat.executeUpdate(query);

            JOptionPane.showMessageDialog(null, "Update Successful!");
            clear();
        }
        catch (SQLException ex)
        {
            Logger.getLogger(STAFF_EDIT.class.getName()).log(Level.SEVERE, null, ex);
        }
        updateButton.setEnabled(false);
        editButton.setEnabled(true);

        }
        // TODO add your handling code here:
}                                            

    private void displayStreetActionPerformed(java.awt.event.ActionEvent evt) {                                              
        // TODO add your handling code here:
    }                                             

    private void findButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
        
        String query = null;
        clear();
        String choice = choiceTextField.getText();
        String combo_select = (String) jComboBox1.getSelectedItem();
        if(combo_select.equals("Select"))
        {
            JOptionPane.showMessageDialog(null, "Please select lookup by first!");
        }
        else if(choice.equals(""))
        {
            JOptionPane.showMessageDialog(null, "Please type in first!");
        }
    else
    {
        if(combo_select.equals("Staff Code")) {
            query = "SELECT * FROM STAFF WHERE STAFF_CODE ="+ choice +"";
        }

        if(combo_select.equals("IC Number")) {
            query = "SELECT * FROM STAFF WHERE STAFF_ICNO ="+ choice +"";
        }
        

       try {
            stat = con.createStatement();
            rset = stat.executeQuery(query);

            if(rset.next()) {

                displayPriviledge.setText(rset.getString("STAFF_CLASS"));
                displayFirstName.setText(rset.getString("STAFF_FNAME"));
                displayLastName.setText(rset.getString("STAFF_LNAME"));
                displayIcNumber.setText(rset.getString("STAFF_ICNO"));
                displayHousePhoneNumber.setText(rset.getString("STAFF_HOUSEPHONE"));
                displaymobilePhoneNumber.setText(rset.getString("STAFF_MOBILEPHONE"));
                displayGender.setText(rset.getString("STAFF_GENDER"));
                displayDOB.setText(rset.getString("STAFF_DOB"));
                displayStreet.setText(rset.getString("STAFF_STREET"));
                displayHouseNum.setText(rset.getString("STAFF_HOUSENO"));
                displayComplex.setText(rset.getString("STAFF_GARDEN"));
                displayCity.setText(rset.getString("STAFF_CITY"));
                displayPostcode.setText(rset.getString("STAFF_POSTCODE"));
                displayState.setText(rset.getString("STAFF_STATE"));
            }

        } catch (SQLException ex) {
            Logger.getLogger(STAFF_DELETE.class.getName()).log(Level.SEVERE, null, ex);
        }
       }
    }                                          

    private void displayHousePhoneNumberActionPerformed(java.awt.event.ActionEvent evt) {                                                        
        // TODO add your handling code here:
    }                                                       

    private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           

       /* if()
        {
            JOptionPane.showMessageDialog(null, "Please Fill and Select first!");
        }
 else
        {*/
        updateButton.setEnabled(true);
        displayIcNumber.setText("");
        displayDOB.setText("");
        displayPriviledge.setText("");
        displayState.setText("");
        displayGender.setText("");

        staffPrivilege.setEnabled(true);
        staffDayComboBox.setEnabled(true);
        staffMonthComboBox.setEnabled(true);
        staffYearComboBox.setEnabled(true);
        genderComboBox.setEnabled(true);
        staffStateComboBox.setEnabled(true);

        displayDOB.setEnabled(false);
        displayPriviledge.setEnabled(false);
        displayState.setEnabled(false);
        displayGender.setEnabled(false);

        displayFirstName.setFocusable(true);
        displayLastName.setFocusable(true);
        displayIcNumber.setFocusable(true);
        displayHousePhoneNumber.setFocusable(true);
        displaymobilePhoneNumber.setFocusable(true);
        displayStreet.setFocusable(true);
        displayHouseNum.setFocusable(true);
        displayComplex.setFocusable(true);
        displayCity.setFocusable(true);
        displayPostcode.setFocusable(true);

        findButton.setEnabled(false);
        editButton.setEnabled(false);
        resetButton.setEnabled(true);

          // TODO add your handling code here:
    }                                          

    private void resetButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            

        clear();
        
        staffPrivilege.setEnabled(false);
        staffDayComboBox.setEnabled(false);
        staffMonthComboBox.setEnabled(false);
        staffYearComboBox.setEnabled(false);
        genderComboBox.setEnabled(false);
        staffStateComboBox.setEnabled(false);

        displayDOB.setEnabled(true);
        displayPriviledge.setEnabled(true);
        displayState.setEnabled(true);
        displayGender.setEnabled(true);

        displayFirstName.setFocusable(false);
        displayLastName.setFocusable(false);
        displayIcNumber.setFocusable(false);
        displayHousePhoneNumber.setFocusable(false);
        displaymobilePhoneNumber.setFocusable(false);
        displayStreet.setFocusable(false);
        displayHouseNum.setFocusable(false);
        displayComplex.setFocusable(false);
        displayCity.setFocusable(false);
        displayPostcode.setFocusable(false);

        findButton.setEnabled(true);
        editButton.setEnabled(true);
        resetButton.setEnabled(false);
        // TODO add your handling code here:
    }                                           

    private void mainMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {                                               

        new MAIN_MENU().setVisible(true);
        this.setVisible(false);// TODO add your handling code here:
    }                                              

    private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
        try {
            new STAFF_RECORD().setVisible(true);
        } catch (SQLException ex) {
            Logger.getLogger(STAFF_EDIT.class.getName()).log(Level.SEVERE, null, ex);
        }
        this.setVisible(false);// TODO add your handling code here:
    }                                          
    
    private void clear()
    {
                displayPriviledge.setText("");
                displayFirstName.setText("");
                displayLastName.setText("");
                displayIcNumber.setText("");
                displayHousePhoneNumber.setText("");
                displaymobilePhoneNumber.setText("");
                displayGender.setText("");
                displayDOB.setText("");
                displayStreet.setText("");
                displayHouseNum.setText("");
                displayComplex.setText("");
                displayCity.setText("");
                displayPostcode.setText("");
                displayState.setText("");
    }

    private void connect() throws SQLException
    {
        DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
        System.out.println("Driver Loaded");
        con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","javaproject","javaproject");
        System.out.println("Database Connected");

    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new STAFF_EDIT().setVisible(true);
                } catch (SQLException ex) {
                    Logger.getLogger(STAFF_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JButton backButton;
    private javax.swing.JTextField choiceTextField;
    private javax.swing.JTextField displayCity;
    private javax.swing.JTextField displayComplex;
    private javax.swing.JTextField displayDOB;
    private javax.swing.JTextField displayFirstName;
    private javax.swing.JTextField displayGender;
    private javax.swing.JTextField displayHouseNum;
    private javax.swing.JTextField displayHousePhoneNumber;
    private javax.swing.JTextField displayIcNumber;
    private javax.swing.JTextField displayLastName;
    private javax.swing.JTextField displayPostcode;
    private javax.swing.JTextField displayPriviledge;
    private javax.swing.JTextField displayState;
    private javax.swing.JTextField displayStreet;
    private javax.swing.JTextField displaymobilePhoneNumber;
    private javax.swing.JButton editButton;
    private javax.swing.JButton findButton;
    private javax.swing.JComboBox genderComboBox;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JButton mainMenuButton;
    private javax.swing.JButton resetButton;
    private javax.swing.JLabel staffAddressDetailLabel;
    private javax.swing.JLabel staffCityLabel;
    private javax.swing.JLabel staffComplexLabel;
    private javax.swing.JLabel staffDOBLabel;
    private javax.swing.JComboBox staffDayComboBox;
    private javax.swing.JLabel staffFirstNameLabel;
    private javax.swing.JLabel staffGenderLabel;
    private javax.swing.JLabel staffHouseLabel;
    private javax.swing.JLabel staffHousephoneLabel;
    private javax.swing.JLabel staffICNumberLabel;
    private javax.swing.JLabel staffLastNameLabel;
    private javax.swing.JLabel staffMobilePhoneLabel;
    private javax.swing.JComboBox staffMonthComboBox;
    private javax.swing.JLabel staffPersonalDetailLabel;
    private javax.swing.JLabel staffPhoneDetailLabel;
    private javax.swing.JLabel staffPostcodeLabel;
    private javax.swing.JComboBox staffPrivilege;
    private javax.swing.JLabel staffPrivilegeLabel;
    private javax.swing.JComboBox staffStateComboBox;
    private javax.swing.JLabel staffStateLabel;
    private javax.swing.JLabel staffStreetLabel;
    private javax.swing.JComboBox staffYearComboBox;
    private javax.swing.JButton updateButton;
    // End of variables declaration                   

}
